const express = require('express')
const app = express()
var cors = require('cors')
const knowledge = require('./knowledge.json')
const paperData = require('./paperData.json')

app.use(cors({
  credentials: true, 
  origin: 'http://localhost:8080'
}))

app.get('/knowledge', function(req, res, next) {
  return res.send(JSON.stringify(knowledge))
})

app.get('/paperData', function(req, res, next) {
  return res.send(JSON.stringify(paperData))
})

const server = app.listen(3002, function () {
  const host = server.address().address
  const port = server.address().port
  console.log('Example app listening at http://%s:%s', host, port)
})